package com.jshx.sz.gdjt.activity;

import android.app.Activity;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.Bundle;
import android.view.Window;

import com.jshx.sz.gdjt.R;

/**
 * 基础activity
 * @author caxiang
 * @time 2013-08-20
 */
public abstract class SuperActivity extends Activity {
	
	protected String TAG = "SuperActivity";
	
	private IntentFilter exitFilter;
	
	private BroadcastReceiver exitBr;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		this.requestWindowFeature(Window.FEATURE_NO_TITLE);
		super.onCreate(savedInstanceState);
		exitFilter = new IntentFilter();
		exitFilter.addAction("android.com.xygzs.exit");
		exitBr = new BroadcastReceiver() 
		{
			@Override
			public void onReceive(Context context, Intent intent) {
				finish();
			}
		};
		this.registerReceiver(exitBr, exitFilter);
	}
	
	@Override
	public void finish()
	{
		if(exitBr != null)
		{
			this.unregisterReceiver(exitBr);
		}
		super.finish();
		overridePendingTransition(R.anim.slide_in, R.anim.slide_out);
	}

	@Override
	public void startActivity(Intent intent) 
	{
		super.startActivity(intent);
		overridePendingTransition(R.anim.slide_right_to_left, R.anim.slide_left_to_right);
	}
}
